# Maintainer: Connor Behan <connor.behan@gmail.com>
# Contributor: mar77i <mysatyre at gmail dot com>

pkgname=ming
pkgver=0.4.8.r68.g04aee523
pkgrel=5
pkgdesc="SWF output library"
arch=('loong64' 'x86_64')
url="http://www.libming.net/"
license=('GPL' 'LGPL')
depends=('freetype2' 'libpng' 'flex' 'giflib')
makedepends=('bison' 'pkgconf' 'swig' 'python' 'git')
options=('!emptydirs')
source=(git+https://github.com/libming/libming.git#commit=04aee52363688426eab74f5d6180c149654a6473 py3.patch ming-0.4.8-swig-4.1.patch)
sha256sums=('SKIP'
            'c33000d71c4e7308c6c4b7a3be05087d6b088b86caa841d0e11585c26cbc1e64'
            '33cca7f5f5b17805a0ca1b56e4ef1e2be3492169bbb8500a3d872b3ac762758e')

pkgver() {
  cd "$srcdir"/libming
  git describe --long | sed 's/^ming-//;s/\([^-]*-g\)/r\1/;s/[-_]/./g'
}

build() {
  cd "$srcdir"/libming
  export CFLAGS="$CFLAGS -fcommon"
  git apply ../py3.patch
  git apply ../ming-0.4.8-swig-4.1.patch

  ./autogen.sh
  PYTHON=/usr/bin/python ./configure --prefix=/usr --enable-python

  # Strange that this can fail when we let the Makefile do it
  pushd src/actioncompiler
  bison -y -p swf4 -b swf4compiler swf4compiler.y
  bison -y -p swf5 -b swf5compiler swf5compiler.y
  popd
  make
}

package() {
  cd "$srcdir"/libming
  make DESTDIR="$pkgdir" install
}
